package techstudy;

import static org.junit.jupiter.api.Assertions.*;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvFileSource;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;

class ParameterizedTestDemo {

	@BeforeAll
	static void setUpBeforeClass() throws Exception {
	}

	@AfterAll
	static void tearDownAfterClass() throws Exception {
	}

	@BeforeEach
	void setUp() throws Exception {
	}

	@AfterEach
	void tearDown() throws Exception {
	}

	@ParameterizedTest
	@ValueSource(strings = { "racecar", "radar", "able was I ere I saw elba" })
	void simpleValueSource(String candidate) {
	    System.out.println(candidate);
	}
	
	
	@ParameterizedTest
	@CsvSource({
	    "r1,1,2,3",
	    "r2,2,2,4"
	})
	void csvInputInCode(String index, int x, int y, int sum) {
		assertEquals(x+y, sum);
	}
	

	@ParameterizedTest
	@CsvFileSource(numLinesToSkip = 1, resources = "csvinput.csv")
	void csvInputInFile(String index, int x, int y, int sum) {
		assertEquals(x+y, sum);
	}

}
